package com.sceneworker.passmonitor;

import javax.swing.Icon;

import com.acarter.composabletree.ComposableTreeNode;
import com.acarter.jmejtree.JMEJTreeIcon;
import com.jme.renderer.pass.BasicPassManager;
import com.jme.renderer.pass.Pass;

public class PassManagerTreeNode implements ComposableTreeNode {

	public Object getChild(Object parent, int index) {
		if(parent instanceof BasicPassManager) {
			return ((BasicPassManager)parent).get(index);
		}
		
		return null;
	}

	public int getChildCount(Object parent) {
		if(parent instanceof BasicPassManager) {
			return ((BasicPassManager)parent).passes();
		}
		
		return 0;
	}

	public int getChildIndex(Object parent, Object child) {
		if(parent instanceof BasicPassManager) {
			BasicPassManager		lcl_mgr = (BasicPassManager)parent;
			for(int li_index = 0; li_index < lcl_mgr.passes(); li_index++) {
				Pass	lcl_pass = lcl_mgr.get(li_index);
				
				if(lcl_pass == child) {
					return li_index;
				}
			}
		}
		
		return -1;
	}

	public Icon getIcon(Object node) {
		return JMEJTreeIcon.getIcon().passNode;
	}

	public Class<?> getNodeClassType() {
		return BasicPassManager.class;
	}

	public String getNodeText(Object node, boolean selected, boolean expanded,
			boolean leaf, int row, boolean hasFocus) {
		return "Pass Manager";
	}

	public String getNodeToolTipText(Object node, boolean selected,
			boolean expanded, boolean leaf, int row, boolean hasFocus) {
		
		return "Pass Manager";
	}

	public Object getParent(Object child) {
		return null;
	}

}
